﻿using Microsoft.SharePoint;

namespace Trentacular.SharePoint.SmartEditorPart.FeatureReceivers
{
    /// <summary>
    /// Base class that makes the feature scope available as an argument to the
    /// FeatureActivated and FeatureDeactivating methods
    /// </summary>
    /// <typeparam name="T">
    /// T is the class type of the scope of the feature (SPFarm, SPWebApplication, SPSite, or SPWeb)
    /// </typeparam>
    public abstract class BaseFeatureReceiver<T> : SPFeatureReceiver
    {
        public sealed override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            FeatureActivated((T)properties.Feature.Parent, properties);
        }

        public virtual void FeatureActivated(T scope, SPFeatureReceiverProperties properties) { }

        public sealed override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            FeatureDeactivating((T)properties.Feature.Parent, properties);
        }

        public virtual void FeatureDeactivating(T scope, SPFeatureReceiverProperties properties) { }
    }
}
